<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<style>
    span.fy {
        display: block;
        background: url(${ctx}/images/fybg.jpg);
        float: right;
        margin-left: 5px;
        width: 47px;
        color: #000000;
        line-height: 21px;
        height: 21px;
        text-align: center;
        cursor: pointer
    }
</style>
<div style="margin: 5px auto 5px;">
    <c:if test="${paginator != null}">
        <c:if test="${paginator.lastPage > 1}">
            <select name=""
                    style="display: block; float: right; margin-left: 5px; height: 21px;"
                    onchange="pageDo(this)">
                <s:iterator begin="1" end="#request.paginator.lastPage" status="sta">
                    <s:if test="#request.page == #sta.index+1">
                        <option value="${sta.index+1}" selected="selected">${sta.index+1}/${paginator.lastPage}</option>
                    </s:if>
                    <s:else>
                        <option value="${sta.index+1}">${sta.index+1}/${paginator.lastPage}</option>
                    </s:else>
                </s:iterator>
            </select>

			<span
                    onclick="pageHref('${paginator.lastPage}')"
                    class="fy">末页</span>
            <c:if test="${paginator.nextExists}">
				<span
                        onclick="pageHref('${paginator.nextPage}')"
                        class="fy">下一页</span>
            </c:if>
            <c:if test="${paginator.previousExists}">
				<span
                        onclick="pageHref('${paginator.previousPage}')"
                        class="fy">上一页</span>
            </c:if>
            <span onclick="pageHref('1')" class="fy">首页</span>
            <div class="clear"></div>
        </c:if>
    </c:if>
</div>

<script type="text/javascript" src="${ctx}/js/global_util.js" />
<script type="text/javascript">
    function pageDo(obj) {
        pageHref(obj.value);
    }
    function pageHref(page) {
        var url = "${ctx}/${pageUrl}";
        if(url.indexOf("?") >=0){
            url += "&page="+page;
        }else{
            url += "?page="+page;
        }
        url += '&${queryString}';
        //如果有搜索的，请将搜索的Form的Id指定为searchForm
        var searchForm = $("#searchForm");
        //alert(searchForm.length);
        //搜索的时候，要同时提交搜索的表单
        if (searchForm != null && searchForm.length > 0) {
            searchForm.attr("action", url);
            searchForm.submit();
        }
        //非搜索时
        else {
            //window.location.href = url;
            pageTo(url);
        }
    }

    function pageTo(url) {
        if(typeof(loadListContent) !=  "undefined"){
            //refreshListContent(url, data);
            $.ajax(url, {
                type : "POST",
                data:{"operation":"select","organizationId":"${organizationId}"},
                dataType : "html",
                cache : false,
                success : function(a) {
                    var obj = $("#windown-content");
                    obj.html("");
                    obj.append(a);
                },
                complete : function() {
                }
            });
        }
    }


</script>